<template>
    <div id="member">
        <!-- 引入返回导航 -->
        <mt-header title="更多功能" fixed>
            <mt-button slot="left" icon="back" @click="handleBack"></mt-button>
        </mt-header>
        <div class="body">
            
            <div class="list-box">
                <div class="listindex">
                    <div style="margin:0 auto;padding-top: 10px;padding-bottom: 15px;">
                    <img src="../../static/img/logo.png" style="margin:0 auto;" />
                    </div>
                </div>
                <!--<div class="listindex">
                    <div class="linkage">
                        <el-select
                          v-model="sheng"
                          @change="choseProvince"
                          placeholder="省级地区">
                          <el-option
                            v-for="item in province"
                            :key="item.id"
                            :label="item.value"
                            :value="item.id">
                          </el-option>
                        </el-select>
                        <el-select
                          v-model="shi"
                          @change="choseCity"
                          placeholder="市级地区">
                          <el-option
                            v-for="item in shi1"
                            :key="item.id"
                            :label="item.value"
                            :value="item.id">
                          </el-option>
                        </el-select>
                        <el-select
                          v-model="qu"
                          @change="choseBlock"
                          placeholder="区级地区">
                          <el-option
                            v-for="item in qu1"
                            :key="item.id"
                            :label="item.value"
                            :value="item.id">
                          </el-option>
                        </el-select>
                        <input type="hidden" name="" :value="area">
                      </div>
                </div>-->
                <div class="listindex">
                    <div class="right">
                        <div>+86</div><input type="text" v-model="form.username" placeholder="请填写手机号码" />
                    </div>
                </div>
                <div class="listindex">
                    <div class="right">
                        <div>密码</div><input type="password" v-model="form.password" placeholder="请设置密码" />
                    </div>
                </div>
                <div class="listindex">
                    <div class="right">
                        <div>注册码</div><input type="text" v-model="form.code" placeholder="填写推荐业务推广码" />
                    </div>
                </div>
                <div class="listindex">
                    <div class="right">
                        <div>商户名称</div><input type="text" v-model="form.nickname"  placeholder="填写企业名称" />
                    </div>
                </div>
                <div class="listindex">
                    <div class="right" style="    font-size: 10px;color: #999;line-height: 18px;">
                        <input type="checkbox" name="idu" id="idu" value="1" style="width: auto;float: none;" />您已经认真阅读《瓦的农庄服务条款》并同意后点击勾选，我们将尽全力保护您的个人信息安全。
                    </div>
                </div>
                <input type="button" name="" value=" 注册 " class="indexinput" @click="gotoUrl('member.list')">
            </div>
            <!-- 轮播图  :url="lunboUrl"-->
            <my-swipe></my-swipe>
        </div>
  
    <br>
    <br>
    <br>
    <br>
    <!-- 全局提示框 -->
        <div v-show="visible" style="position: fixed;background: #000; width: 100%;height: 100%;z-index: 99;top: 0px;" @click="gotovisible">
      <div class="dialog-tips dialog-center">
          <div>{{message}}</div>
      </div>
        </div>
  </div>
</template>

<script>
export default {
    name: 'member.register',
  data () {
    return {
        visible: false,
            message: "",
        form:{
            username:'',
            password:'',
            code:'',
            nickname:''
        },
      /*mapJson:'index/city',//http://wo.kzll.xyz/static/json/map.json',
      province:'',
      sheng: '',
      shengname: '',
      shi: '',
      shiname: '',
      shi1: [],
      qu: '',
      quname: '',
      qu1: [],
      city:'',
      block:'',
      area:'',
*/
    }
  },
  methods:{
    handleBack(){
                this.$router.go(-1); //根据浏览器记录返回上一次
            },
        gotoUrl(url) {
            let datago = 'username::'+this.form.username+',password::'+this.form.password+'::md5,code::'+this.form.code+',nickname::'+this.form.nickname;
            let datagoto = 'username::'+this.form.username+',password::'+this.form.password+'::md5';

            this.$ajax.get('index/save?tbname=member&data=' + datago)
                .then(res=>{

                    if(res.data.data > 0){

                        this.$ajax.get('index/save?tbname=member_test&data=' + datagoto)
                        .then(resn=>{
                            
                            if(resn.data.data > 0){
                                // 命名的路由
                                // this.$router.push({ name: url, params: { username: this.username }});
                                
                                this.message = '注册成功！';
                                this.visible = true;
                                
                                this.$router.push({ name: url, params: { username: this.form.username, id: res.data.data }});
                            }else{
                                this.message = '注册失败！';
                                this.visible = true;
                            }
                        })
                        .catch(errn=>{
                            console.log(errn);
                        });
                         
                    }else{
                        this.message = '注册失败！';
                        this.visible = true;
                    }
                    
                })
                .catch(err=>{
                    console.log(err);
                })
            
        },
        gotovisible(){
            this.visible = false;
        },
    // 加载china地点数据，三级
      /*getCityData:function(){
        var that = this
        this.$ajax.get(this.mapJson).then(function(response){
          if (response.status==200) {
            var data = response.data
            that.province = []
            that.city = []
            that.block = []
            // 省市区数据分类
            for (var item in data) {
              if (item.match(/0000$/)) {//省
                that.province.push({id: item, value: data[item], children: []})
              } else if (item.match(/00$/)) {//市
                that.city.push({id: item, value: data[item], children: []})
              } else {//区
                that.block.push({id: item, value: data[item]})
              }
            }
            // 分类市级
            for (var index in that.province) {
              for (var index1 in that.city) {
                if (that.province[index].id.slice(0, 2) === that.city[index1].id.slice(0, 2)) {
                  that.province[index].children.push(that.city[index1])
                }
              }
            }
            // 分类区级
            for(var item1 in that.city) {
              for(var item2 in that.block) {
                if (that.block[item2].id.slice(0, 4) === that.city[item1].id.slice(0, 4)) {
                  that.city[item1].children.push(that.block[item2])
                }
              }
            }
          }
          else{
            console.log(response.status)
          }
        }).catch(function(error){console.log(typeof+ error)})
      },
      // 选省
      choseProvince:function(e) {
        for (var index2 in this.province) {
          if (e === this.province[index2].id) {
            this.shengname = this.province[index2].value;//jjj
            this.shi1 = this.province[index2].children
            this.shi = this.province[index2].children[0].value
            this.shiname = this.province[index2].children[0].value//jjj
            this.qu1 =this.province[index2].children[0].children
            this.qu = this.province[index2].children[0].children[0].value
            this.quname = this.province[index2].children[0].children[0].value;//jjj
            this.E = this.qu1[0].id
            this.area = this.shengname+','+this.shiname+','+this.quname;
            // console.log(this.shi1,this.shi,this.qu1,this.qu,this.E)
          }
        }
      },
      // 选市 children
      choseCity:function(e) {
        for (var index3 in this.city) {
          if (e === this.city[index3].id) {
            this.shiname = this.city[index3].value;//jjj
            if(this.city[index3].children.length > 0){
                this.qu1 = this.city[index3].children
                this.qu = this.city[index3].children[0].value
                this.quname = this.city[index3].children[0].value
                this.E = this.qu1[0].id
                this.area = this.shengname+','+this.shiname+','+this.quname;
                // console.log(this.qu1,this.qu,this.E)
            }else{
                this.qu1 = ''
                this.qu = ''
                this.E = ''
                this.area = this.shengname+','+this.shiname;
            }
          }
        }
      },
      // 选区
      choseBlock:function(e) {
        this.E=e;
        for (var index4 in this.qu1) {
            if (e === this.qu1[index4].id) {
                this.quname = this.qu1[index4].value;
            }
        }
        this.area = this.shengname+','+this.shiname+','+this.quname;
        // console.log(this.sheng,this.shengname,this.shi,this.shiname,this.E,this.quname)
      },*/
    },
    created:function(){
      //this.getCityData()
    }
}
</script>

<style scoped>
.dialog-tips{
    position: fixed;
    z-index: 100;
    min-width: 220px;
    padding: 40px 22px;
    white-space: nowrap;
    background-color: #fff;
    box-shadow: 0px 8px 15px 0 rgba(0, 0, 0, 0.1);
    text-align: center;
    .dialog-tips-icon{
        width: 54px;
        height: 54px;
        @extend %bg-contain;
        display: inline-block;
        margin-bottom: 13px;
    }
}
.dialog-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%)
}
.linkage {
    width: 100%; margin:0 auto;
}
.el-select {
    float: left; width: 33%;
}
.indexinput {
        margin: 0 auto;
    border-radius: 5px;
    display: grid;
    width: 50%;
    text-align: center;
    background-color: #a3dea4;
    border: none;
    color: white;
}
.listindex ul {
    width: 100%; /*margin:0 auto;*/
}

.listindex ul li {
    float: left; width: 25%;font-size: 12px;text-align: center;
list-style:none;
}
.listindex ul li#li {
    padding-left: 10px; padding-right: 10px;float: left; width: 5%;
}

.icon-zuojiantou:before {
    color: #999;
}
/*lang="less"*/
    #member .header {
        background-color: rgba(0, 0, 0, 0.8);
        padding-bottom: 40%;
        border-radius: ~"0px 0px 50% 50% / 0px 0px 20% 20%;";
        position: relative;
    }
        #member .header .header-content {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }
            #member .header .header-content .header-img {
                width: 80px;
                height: 80px;
                border-radius: 50%;
                background-color: #fff;
                display: flex;
                justify-content: center;
                align-items: center;
            }
                #member .header .header-content .header-img img {
                    height: 90%;
                    width: 90%;
                    border-radius: 50%;
                }
            #member .header .header-content .name {
                font-size: 15px;
                text-align: center;
                color: #fff;
            }
        #member .header .setting {
            position: absolute;
            right: 10px;
            top: 10px;
            
        }
        #member .body {
            margin-top: 50px;
        }
        
        #member .body .my-order {
            margin: 20px 0;
        }
            #member .body .my-order .order-icon {
                display: flex;
                justify-content: center;
                align-items: center;
            }
                #member .body .my-order .order-icon div {
                    flex: 1;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    flex-direction: column;
                    font-size: 12px;
                }
                    #member .body .my-order .order-icon div .svg-icon {
                        margin: 10px 0;
                    }
        #member .body .list-box{
            width: 95%;
            margin: 0 auto;
        }
            #member .body .list-box .listindex:nth-child(1) , #member .body .list-box .listindex:nth-child(2) {
                margin: 10px 0;
            }
            #member .body .list-box .listindex {
               
                display: grid;
                align-items: center;
                /*padding: 0px 20px;
                border-radius: 3px;
                border: 1px solid #ddd;*/

            }
                #member .body .list-box .listindex .right {
                    padding: 5px;
                    line-height: 40px;
                }
                    #member .body .list-box .listindex .right div {
                        width: 20%; float: left;
                    }
                    #member .body .list-box .listindex .right input {
                        width: 80%; float: left;
                    }
</style>
